package designModel.singleInstance;

public class Singleton_02 {
    private static Singleton_02 instance;

    private Singleton_02() {
    }

    //添加同步锁
    public static synchronized Singleton_02 getInstance() {
        if (instance == null) {
            instance = new Singleton_02();
        }
        return instance;
    }

    public void doSomething() {
        System.out.println(getClass().getSimpleName() + ":带有同步锁的单例");
    }
}
